import { title } from 'process'
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'

const router = createRouter({
	history: createWebHistory(import.meta.env.BASE_URL),
	routes: [
		{
			path: '/',
			name: 'Index',
			redirect: '/home',
			component: () => import("@/views/index.vue"),
			children: [
				{
					path: '/home',
					name: 'Home',
					component: () => import('@/views/home/index.vue'),
					meta: { title: '首页' }
				},
				{
					path: '/user',
					name: 'User',
					component: () => import('@/views/user/index.vue'),
					meta: { title: '用户管理' }
				},
				{
					path: '/perm',
					name: 'Perm',
					component: () => import('@/views/perm/index.vue'),
					meta: { title: '权限管理' }
				},
				{
					path: '/role',
					name: 'Role',
					component: () => import('@/views/role/index.vue'),
					meta: { title: '角色管理' }
				},
				{
					path: '/device',
					name: 'Device',
					redirect: { name: 'Info' },
					meta: { title: '设备管理' },
					children: [
						{
							path: 'info',
							name: 'Info',
							component: () => import('@/views/device/info/index.vue'),
							meta: { title: '设备信息' }
						},
						{
							path: 'maintain',
							name: 'Maintain',
							component: () => import('@/views/device/maintain/index.vue'),
							meta: { title: '设备维修' }
						},
						{
							path: 'threshold',
							name: 'Threshold',
							component: () => import('@/views/device/threshold/index.vue'),
							meta: { title: '设备阈值' }
						},
						{
							path: 'data',
							name: 'Data',
							component: () => import('@/views/device/data/index.vue'),
							meta: { title: '设备数据' }
						}
					]
				},
				{
					path: '/alarm',
					name: 'Alarm',
					redirect: { name: 'AlarmLog' },
					meta: { title: '告警管理' },
					children: [
						{
							path: 'log',
							name: 'AlarmLog',
							component: () => import('@/views/alarm/log/index.vue'),
							meta: { title: '告警日志' }
						}
					]
				},
				{
					path: 'class',
					name: 'Class',
					redirect: {},
					meta: { title: '班级管理' },
					children: [
						{
							path: 'info',
							name: 'ClassInfo',
							component: () => import('@/views/class/info/index.vue'),
							meta: { title: '班级信息' }
						},
						{
							path: 'group',
							name: 'ClassGroup',
							component: () => import('@/views/class/group/index.vue'),
							meta: { title: '成员分组' }
						}
					]
				},
			]
		},
		{
			path: '/login',
			name: 'Login',
			component: () => import('@/views/auth/login/index.vue'),
		}
	] as RouteRecordRaw[],
})

export default router
